<template>
	<view class="">
		<uni-nav-bar shadow  @clickLeft="back" height="88rpx" :border="false" :fixed="true"
			backgroundColor="#FFFFFF" :shadow="false" left-icon="left"></uni-nav-bar>
		<view  class="canOpen CanOpenInvoice InvoiceList">
			<view class="">
				<text class="allMoney">可开发票总金额（元）</text>
				<view class="money">¥{{InovoiceMoney}}</view>
			</view>
			<text @click="toAdd()" class="openBtn">立即开票</text>
		</view>
		<view class="InvoiceList" v-for="i in InvoiceList">

			<view>
				<view class="flex flexBetween">
					<text style="font-weight: bold;font-size: 28rpx;"> {{i.name}}</text>
					<text class="alreadyOpen">已开票</text>
				</view>
				<text>{{i.remark}}</text>
				<view class="flex flexBetween">{{i.money}}
					<text class="wlIcon-fanhui2 margin-left-xs"></text>
				</view>
				<text>{{i.createtime}} </text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				InvoiceList: [],
				InovoiceMoney: null
			};
		},
		onLoad(options) {
			this.getInvoiceList()
		},
		onShow() {
				this.getInvoiceList()
		},
		methods: {
			back() {
				uni.navigateBack({
					delta:1
				})
			},
			getInvoiceList() {
				this.$api.post({
					url: '/wanlshop.Invoice/getinvoice',
					data: {}
				}).then(res => {
					this.InvoiceList = res.data_list
					this.InovoiceMoney = res.total_money
				})
			},
			toAdd() {
				if(this.InovoiceMoney>0){
					uni.navigateTo({
						url: '/pages/user/Invoice/add'
					})	
				}else{
					uni.showToast({
						title:'当前可开票金额为0',
						icon:"error"
					})
				}
				
			}
		}
	};
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.InvoiceList {
		margin: 10rpx auto;
		width: 690rpx;
		height: 208rpx;
		background-color: #fff;
		border-radius: 8px 8px 8px 8px;
		opacity: 1;
		padding: 20rpx;
		box-sizing: border-box;
}
		.canOpen {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 100%;
		}

		.allMoney {
			font-size: 10px;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}

		.money {
			font-size: 46rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			margin-top: 10rpx;
		}

		.openBtn {
			width: 150rpx;
			height: 60rpx;
			background: #FFFFFF;
			border-radius: 2px 2px 2px 2px;
			opacity: 1;
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: 600;
			color: #86C8A0;
			text-align: center;
			line-height: 60rpx;
		}

		.alreadyOpen {
			width: 80rpx;
			height: 32rpx;
			background: #00D03F;
			border-radius: 1px 1px 1px 1px;
			opacity: 1;
			font-size: 10px;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			text-align: center;
		}
	

	.CanOpenInvoice {
		background: linear-gradient(100deg, #8ECBA6 0%, #3FBF70 100%);
	}

	.flexBetween {
		justify-content: space-between;
		align-items: center;
	}
</style>
